package dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

import util.ConnectDataBase;
import model.Category;
import model.Customer;

public class CategoryDAO {
	Vector listcategory;
	ConnectDataBase connectDataBase;

	public CategoryDAO() {

		listcategory = new Vector();
		connectDataBase = new ConnectDataBase();
	}

	public Vector getListcategory() {
		try {

			ResultSet rs = connectDataBase
					.query_select("Select * From Category");
			while (rs.next()) {
				String id = rs.getString("category_id");
				String name = rs.getString("category_name");
				Category ce = new Category(id, name);
				listcategory.add(ce);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return listcategory;
	}

	public void insert_Category(Category category) {

		String sql = "Insert into Category values('"
				+ category.getCategory_id() + "','"
				+ category.getCategory_name() + "')";

		connectDataBase.query_update(sql);
	}

	public void delete_Category(Category category) {
		String sql = "Delete from Category where category_id="
				+ category.getCategory_id();
		connectDataBase.query_update(sql);
	}

	// public Category findbyid(int customer_id) {
	// Category re = null;
	//
	// try {
	// ResultSet rs = connectDataBase
	// .query_select("Select * From Category from category_id="
	// + customer_id);
	// while (rs.next()) {
	// String id = rs.getString("category_id");
	// String name = rs.getString("category_name");
	// re = new Category(id, name);
	// }
	// } catch (SQLException e) {
	// // TODO Auto-generated catch block
	// e.printStackTrace();
	// }
	// return re;
	//
	// }

}
